﻿using System;
using System.Runtime.Caching;

public class TokenConnectionCacheStore
{
    private static readonly object CacheLock = new object();

    public static object GetCachedData(string CacheKey)
    {
        MemoryCache cache = MemoryCache.Default;
        return cache.Get(CacheKey);
    }


    public static void SetCachedData(string CacheKey, object data)
    {
        MemoryCache cache = MemoryCache.Default;

        lock (CacheLock)
        {
            CacheItemPolicy policy = new CacheItemPolicy
            {
                AbsoluteExpiration = DateTimeOffset.Now.AddDays(1)
            };

            cache.Set(CacheKey, data, policy);
        }
    }

    public static void RemoveCachedData(string CacheKey)
    {
        lock (CacheLock)
        {
            MemoryCache cache = MemoryCache.Default;
            cache.Remove(CacheKey);
        }
       
    }
}